




/*
'===============================================================================
'  MP.LayerHelper.MP_OBS.BL.MbModulesManagerBase
'===============================================================================
*/

using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using MP.LayerHelper.MP_OBS.BLL;
using MP.LayerHelper.MP_OBS.DAL;
using MP.LayerHelper.MP_OBS.DAL.EntityClasses;
using MP.LayerHelper.MP_OBS.DAL.FactoryClasses;
using MP.LayerHelper.MP_OBS.DAL.HelperClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;

namespace MP.LayerHelper.MP_OBS.BLL
{
	public class MbModulesManagerBase : ManagerBase
	{
		/// <summary>
		/// Purpose: Class constructor.
		/// </summary>
		
		public MbModulesManagerBase()
		{
			// Nothing for now.
		}
		
		public override string TableName()
        {
            return "MbModules";
        }
		
		public MbModulesEntity Insert(MbModulesEntity _MbModulesEntity)
		{
			return Insert(_MbModulesEntity, "");
		}
		
		public MbModulesEntity Insert(MbModulesEntity _MbModulesEntity, string controlId)
		{
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.SaveEntity(_MbModulesEntity, true);
				MbModulesFields field = new MbModulesFields();
                LogEntity(_MbModulesEntity, field, AcInsert, controlId);
			}
			return _MbModulesEntity;
		}

		
		public MbModulesEntity Insert(string ModCode, string ModName, bool IsEnable, string ParentCode, Guid DepartId)
		{
			MbModulesEntity _MbModulesEntity = new MbModulesEntity();
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				
				_MbModulesEntity.ModCode = ModCode;
				_MbModulesEntity.ModName = ModName;
				_MbModulesEntity.IsEnable = IsEnable;
				_MbModulesEntity.ParentCode = ParentCode;
				_MbModulesEntity.DepartId = DepartId;
				MbModulesFields field = new MbModulesFields();
                LogEntity(_MbModulesEntity, field, AcInsert);
				adapter.SaveEntity(_MbModulesEntity, true);
			}
			return _MbModulesEntity;
		}

		public MbModulesEntity Insert(string ModName, bool IsEnable, string ParentCode, Guid DepartId)
		{
			MbModulesEntity _MbModulesEntity = new MbModulesEntity();
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				
				_MbModulesEntity.ModName = ModName;
				_MbModulesEntity.IsEnable = IsEnable;
				_MbModulesEntity.ParentCode = ParentCode;
				_MbModulesEntity.DepartId = DepartId;
				adapter.SaveEntity(_MbModulesEntity, true);
				MbModulesFields field = new MbModulesFields();
                LogEntity(_MbModulesEntity, field, AcInsert);
			}
			return _MbModulesEntity;
		}
		
		public bool Update(MbModulesEntity _MbModulesEntity)
        {
            return Update(_MbModulesEntity, "");
        }

		public bool Update(MbModulesEntity _MbModulesEntity, string controlId)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				RelationPredicateBucket filter = new RelationPredicateBucket();
				IPredicateExpression _PredicateExpression = new PredicateExpression();
				_PredicateExpression.Add(MbModulesFields.ModCode == _MbModulesEntity.ModCode);
					
				filter.PredicateExpression.Add(_PredicateExpression);

				adapter.UpdateEntitiesDirectly(_MbModulesEntity, filter);
				toReturn = true;
				
				MbModulesFields field = new MbModulesFields();
                LogEntity(_MbModulesEntity, field, AcUpdate, controlId);
			}
			return toReturn;
		}
		
		public bool Update(MbModulesEntity _MbModulesEntity, RelationPredicateBucket filter)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.UpdateEntitiesDirectly(_MbModulesEntity, filter);
				toReturn = true;
				
				MbModulesFields field = new MbModulesFields();
                LogEntity(_MbModulesEntity, field, AcUpdate);
			}
			return toReturn;
		}

		public bool Update(string ModCode, string ModName, bool IsEnable, string ParentCode, Guid DepartId)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				MbModulesEntity _MbModulesEntity = new MbModulesEntity(ModCode);
				if (adapter.FetchEntity(_MbModulesEntity))
				{
				
					_MbModulesEntity.ModName = ModName;
					_MbModulesEntity.IsEnable = IsEnable;
					_MbModulesEntity.ParentCode = ParentCode;
					_MbModulesEntity.DepartId = DepartId;
					adapter.SaveEntity(_MbModulesEntity, true);
					toReturn = true;
					
					MbModulesFields field = new MbModulesFields();
					LogEntity(_MbModulesEntity, field, AcUpdate);
				}
			}
			return toReturn;
		}

		public bool Delete(string ModCode)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				MbModulesEntity _MbModulesEntity = new MbModulesEntity(ModCode);
				if (adapter.FetchEntity(_MbModulesEntity))
				{
					adapter.DeleteEntity(_MbModulesEntity);
					toReturn = true;
				}
			}
			return toReturn;
		}
		
		public void DeleteAll() 
		{
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.DeleteEntitiesDirectly("MbModulesEntity", null);
			}
		}
		
		
		public int DeleteByModCode(string ModCode)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbModulesFields.ModCode == ModCode);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MbModulesEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByModName(string ModName)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbModulesFields.ModName == ModName);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MbModulesEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByIsEnable(bool IsEnable)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbModulesFields.IsEnable == IsEnable);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MbModulesEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByParentCode(string ParentCode)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbModulesFields.ParentCode == ParentCode);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MbModulesEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByDepartId(Guid DepartId)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbModulesFields.DepartId == DepartId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MbModulesEntity", filter);
			}
			return toReturn;
		}
		

		
		public MbModulesEntity SelectOne(string ModCode)
		{
			MbModulesEntity toReturn = null;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				MbModulesEntity _MbModulesEntity = new MbModulesEntity(ModCode);
				if (adapter.FetchEntity(_MbModulesEntity))
				{
					toReturn = _MbModulesEntity;
				}
			}
			return toReturn;
		}

		// Return DataTable
		public DataTable SelectAllRDT()
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbModulesCollection = new EntityCollection(new MbModulesEntityFactory());
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbModulesCollection.EntityFactoryToUse.CreateFields(), toReturn, null, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection<MbModulesEntity>
		public EntityCollection<MbModulesEntity> SelectAllLST()
		{
			EntityCollection<MbModulesEntity> _MbModulesCollection = new EntityCollection<MbModulesEntity>();
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbModulesCollection, null, 0, null);
			}
			return _MbModulesCollection;
		}
		
		// Return EntityCollection<MbModulesEntity>
		public EntityCollection<MbModulesEntity> SelectAllLST_Paged(int PageNumber, int PageSize)
		{
			EntityCollection<MbModulesEntity> _MbModulesCollection = new EntityCollection<MbModulesEntity>();
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbModulesCollection, null, 0, null, null, PageNumber, PageSize);
			}
			return _MbModulesCollection;
		}


		
		// Return EntityCollection<MbModulesEntity>
		public EntityCollection<MbModulesEntity> SelectByModCodeLST(string ModCode)
		{
			EntityCollection<MbModulesEntity> _MbModulesCollection = new EntityCollection<MbModulesEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbModulesFields.ModCode == ModCode);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbModulesCollection, filter, 0, null);
			}
			return _MbModulesCollection;
		}
		
		// Return EntityCollection<MbModulesEntity>
		public EntityCollection<MbModulesEntity> SelectByModCodeLST_Paged(string ModCode, int PageNumber, int PageSize)
		{
			EntityCollection<MbModulesEntity> _MbModulesCollection = new EntityCollection<MbModulesEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbModulesFields.ModCode == ModCode);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbModulesCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MbModulesCollection;
		}
		
		// Return DataTable
		public DataTable SelectByModCodeRDT(string ModCode)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbModulesCollection = new EntityCollection(new MbModulesEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbModulesFields.ModCode == ModCode);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbModulesCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByModCodeRDT_Paged(string ModCode, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbModulesCollection = new EntityCollection(new MbModulesEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbModulesFields.ModCode == ModCode);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbModulesCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MbModulesEntity>
		public EntityCollection<MbModulesEntity> SelectByModNameLST(string ModName)
		{
			EntityCollection<MbModulesEntity> _MbModulesCollection = new EntityCollection<MbModulesEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbModulesFields.ModName == ModName);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbModulesCollection, filter, 0, null);
			}
			return _MbModulesCollection;
		}
		
		// Return EntityCollection<MbModulesEntity>
		public EntityCollection<MbModulesEntity> SelectByModNameLST_Paged(string ModName, int PageNumber, int PageSize)
		{
			EntityCollection<MbModulesEntity> _MbModulesCollection = new EntityCollection<MbModulesEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbModulesFields.ModName == ModName);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbModulesCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MbModulesCollection;
		}
		
		// Return DataTable
		public DataTable SelectByModNameRDT(string ModName)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbModulesCollection = new EntityCollection(new MbModulesEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbModulesFields.ModName == ModName);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbModulesCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByModNameRDT_Paged(string ModName, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbModulesCollection = new EntityCollection(new MbModulesEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbModulesFields.ModName == ModName);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbModulesCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MbModulesEntity>
		public EntityCollection<MbModulesEntity> SelectByIsEnableLST(bool IsEnable)
		{
			EntityCollection<MbModulesEntity> _MbModulesCollection = new EntityCollection<MbModulesEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbModulesFields.IsEnable == IsEnable);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbModulesCollection, filter, 0, null);
			}
			return _MbModulesCollection;
		}
		
		// Return EntityCollection<MbModulesEntity>
		public EntityCollection<MbModulesEntity> SelectByIsEnableLST_Paged(bool IsEnable, int PageNumber, int PageSize)
		{
			EntityCollection<MbModulesEntity> _MbModulesCollection = new EntityCollection<MbModulesEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbModulesFields.IsEnable == IsEnable);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbModulesCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MbModulesCollection;
		}
		
		// Return DataTable
		public DataTable SelectByIsEnableRDT(bool IsEnable)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbModulesCollection = new EntityCollection(new MbModulesEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbModulesFields.IsEnable == IsEnable);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbModulesCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByIsEnableRDT_Paged(bool IsEnable, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbModulesCollection = new EntityCollection(new MbModulesEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbModulesFields.IsEnable == IsEnable);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbModulesCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MbModulesEntity>
		public EntityCollection<MbModulesEntity> SelectByParentCodeLST(string ParentCode)
		{
			EntityCollection<MbModulesEntity> _MbModulesCollection = new EntityCollection<MbModulesEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbModulesFields.ParentCode == ParentCode);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbModulesCollection, filter, 0, null);
			}
			return _MbModulesCollection;
		}
		
		// Return EntityCollection<MbModulesEntity>
		public EntityCollection<MbModulesEntity> SelectByParentCodeLST_Paged(string ParentCode, int PageNumber, int PageSize)
		{
			EntityCollection<MbModulesEntity> _MbModulesCollection = new EntityCollection<MbModulesEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbModulesFields.ParentCode == ParentCode);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbModulesCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MbModulesCollection;
		}
		
		// Return DataTable
		public DataTable SelectByParentCodeRDT(string ParentCode)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbModulesCollection = new EntityCollection(new MbModulesEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbModulesFields.ParentCode == ParentCode);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbModulesCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByParentCodeRDT_Paged(string ParentCode, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbModulesCollection = new EntityCollection(new MbModulesEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbModulesFields.ParentCode == ParentCode);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbModulesCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MbModulesEntity>
		public EntityCollection<MbModulesEntity> SelectByDepartIdLST(Guid DepartId)
		{
			EntityCollection<MbModulesEntity> _MbModulesCollection = new EntityCollection<MbModulesEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbModulesFields.DepartId == DepartId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbModulesCollection, filter, 0, null);
			}
			return _MbModulesCollection;
		}
		
		// Return EntityCollection<MbModulesEntity>
		public EntityCollection<MbModulesEntity> SelectByDepartIdLST_Paged(Guid DepartId, int PageNumber, int PageSize)
		{
			EntityCollection<MbModulesEntity> _MbModulesCollection = new EntityCollection<MbModulesEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbModulesFields.DepartId == DepartId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbModulesCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MbModulesCollection;
		}
		
		// Return DataTable
		public DataTable SelectByDepartIdRDT(Guid DepartId)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbModulesCollection = new EntityCollection(new MbModulesEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbModulesFields.DepartId == DepartId);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbModulesCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByDepartIdRDT_Paged(Guid DepartId, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbModulesCollection = new EntityCollection(new MbModulesEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbModulesFields.DepartId == DepartId);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbModulesCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		

	}
}
